//
// Created by Mark on 2021/4/8.
//

#ifndef INXRSENSOR_CLIENT_H
#define INXRSENSOR_CLIENT_H

#include <stdlib.h>
#include "NxrSensorTypes.h"
#include <map>

using namespace nxr_client;

namespace android {
    class INxrSensorClient {
    public:
        virtual ~INxrSensorClient(){};
        
        virtual bool init() = 0;
        virtual int32_t getClientVersion() = 0;
        virtual int32_t getServiceVersion() = 0;
        virtual void pause() = 0;
        virtual void resume() = 0;
        virtual void setTrackingMode(int32_t mode) = 0;
        virtual bool getHeadInfo(long prediction,float *dest,int length) = 0;
        virtual bool getHeadEuler(long prediction,double *dest,int length) = 0;
        virtual void destroy() = 0;
        virtual void reset() = 0;
        virtual bool is6Dof() = 0;
        virtual bool isSupportMatrix() = 0;
        virtual void setParameterI(int key,int value) = 0;
        virtual int getParameterI(int key) = 0;
        virtual void updateFeedData(void *feed) = 0;
        virtual bool getFeedData(void *dest) = 0;
        virtual bool getTrackingData(void *dest) = 0;
		virtual bool getNxrRawData(void *dest) = 0;
        virtual bool isSupportSlam() = 0;
        virtual void setParameterIA(int key,int *values,int length) = 0;
        virtual int getParameterIA(int key,int *result,int length) = 0;
		virtual bool switchVRMode(int mode) = 0;
		//for nxrslam 
        virtual bool initNxrSlam() = 0;
        virtual void pauseNxrSlam() = 0;
        virtual void resumeNxrSlam() = 0;
        virtual void destroyNxrSlam() = 0;
        virtual void setNxrSlamParameterI(int key,int value) = 0;
        virtual int getNxrSlamParameterI(int key) = 0;
        virtual int getNxrSlamPoseData(float *result,int length) = 0;
		//for vsc
        virtual bool initVSC() = 0;
        virtual void uninitVSC() = 0;
        virtual bool startStreaming(StreamType type,void(*f)(StreamType , NxrStreamData *)) = 0;
		virtual bool startStreamingV2(StreamType type,void(*f)(StreamType , NxrStreamV2 *)) = 0;
        virtual bool stopStreaming(StreamType type) = 0;
        virtual bool hidWrite(unsigned char *buff,int length) = 0;
        virtual bool hidRead(unsigned char *buff,int length) = 0;
        virtual bool loadMapAndSwitchToCslam(const char* filename,void(*f1)(int quality),void(*f2)(float percent)) = 0;
        virtual bool saveMapAndSwitchToCslam(const char* filename,void(*f1)(int status,int quality),void(*f2)(float percent)) = 0;
        virtual bool switchToCslam(void(*f1)(int quality),void(*f2)(float percent)) = 0;
        virtual bool isSupportFeature(Feature feature) = 0;
        virtual bool startPlaneDetection(void(*f)(NxrPlaneData *)) = 0;
        virtual bool stopPlaneDetection() = 0;
        virtual bool readStereoFisheyesCalibration(FishEyeCalibration &calibration) = 0;
        virtual bool readStereoFisheyesCalibration(FishEyeCalibration &calibration,int &imu_fisheye_shift_us) = 0;
        virtual bool readStereoFisheyesPDMCalibration(FishEyePDMCalibration &calibration) = 0;
        virtual bool readTofCalibration(TOFCalibration &calibration) = 0;
        virtual bool readRgbCalibration(RGBCalibration &calibration) = 0;
        virtual bool readDisplayCalibration(NxrDisplayCalibration *calibration) = 0;

        virtual void enableExternalData(bool enable) = 0;
        virtual void updateExternalData(float *roatition,float *translation,float *gyro) = 0;
        virtual bool extract3dPointsFromMap(const char *map,const char *out) = 0;
        virtual int redefineMapCoordinateFromTag(const char *inputMapFile,const char *outMapFile) = 0;
        virtual int redefineMapCoordinateFromTag(const char *inputMapFile,const char *outMapFile,double tag_square_size) = 0;
        virtual int detectTag(float *rotation,float *translation,uint8_t *confidence) = 0;
        virtual int detectTag(float *rotation,float *translation,uint8_t *confidence,double tag_square_size) = 0;
        virtual bool hidWriteAndRead(unsigned char *write,int wLen,unsigned char *read,int rLen) = 0;
        virtual int registerDetectTagCallback(fn_detect_tag_callback cb,double tag_square_size,int subsample_rate) = 0;
        virtual void unregisterDetectTagCallback(int id) = 0;
        virtual bool setDescriptor(const char *filepath) = 0;
        virtual bool setModel(const char *filepath) = 0;
        virtual bool setSource(int source) = 0;
        virtual int getSource() = 0;
        virtual Descriptor getDescriptor() = 0;
    
        virtual bool startSkeleton(int type,fn_skeleton_callback cb) = 0;
        virtual bool stopSkeleton(int type) = 0;
        virtual bool startGesture(int type,fn_gesture_callback cb) = 0;
        virtual bool stopGesture(int type) = 0;
        
        virtual bool getTrackingDataAt(NxrTrackingData *data,uint64_t timestamp) = 0;

        virtual std::string startTagDetector(std::string const &tagFamliy,double size,double refreshRate) = 0;
        virtual bool stopTagDetector(std::string const &detectorId) = 0;
        virtual std::map<int,NxrTrackingData> getTagDetections(std::string const &detectorId) = 0;
        virtual void setTagsMap(std::string const &tagFamliy,double tagSize,std::vector<int> tagIds,std::vector<NxrTrackingData> transforms) = 0;
        virtual bool getTrackingDataInTagsMap(NxrTrackingData *data,double prediction) = 0;

        virtual std::map<std::string,std::string> getXvDeviceInfo() = 0;

        virtual void setConfigPath(const char *path) = 0;
        virtual void registerPoseCallback(void(*f)(NxrTrackingData *data)) = 0;
        virtual bool displayOpen() = 0;
        virtual bool displayClose() = 0;
        virtual int registerColorDepthImageCallback(void(*f)(NxrStreamData *data)) = 0;
        virtual bool unregisterColorDepthImageCallback(int callbackId) = 0;
        virtual bool depthImageToPointCloud(NxrStream *stream,NxrPointCloud *cloud) = 0;
        virtual bool get3dof(NxrTrackingData *result,double prediction) = 0;
        virtual bool get3dofAt(NxrTrackingData *result,double timestamp) = 0;
        virtual bool micStart() = 0;
        virtual bool micStop() = 0;
        virtual int registerMicCallback(void(*f)(NxrMicData *data)) = 0;
        virtual bool unregisterMicCallback(int callbackId) = 0;
        virtual bool speakerEnable() = 0;
        virtual bool speakerDisable() = 0;
        virtual int speakerSend(unsigned char *value,int len) = 0;
        virtual bool speakerPlay(const char *path) = 0;
        virtual bool speakerPlay(unsigned char *value,int len) = 0;
        virtual bool speakerIsPlaying() = 0;
        virtual int registerSpeakerCallback(void(*f)()) = 0;
        virtual bool unregisterSpeakerCallback(int callbackId) = 0;
        virtual bool sgbmStart(const char *sgbmConfig) = 0;
        virtual bool sgbmStop() = 0;
        virtual int registerSgbmCallback(void(*f)(NxrStreamData *data)) = 0;
        virtual bool unregisterSgbmCallback(int callbackId) = 0;
        virtual bool sgbmSetConfig(const char *sgbmConfig) = 0;
        virtual bool control(NxrDeviceSetting setting) = 0;
        virtual bool uvcWriteAndRead(unsigned char *write,int wLen,unsigned char *read,int rLen) = 0;
        virtual bool vscWriteAndRead(unsigned char *write,int wLen,unsigned char *read,int rLen) = 0;
        virtual NxrVersion version() = 0;
        virtual void setLogLevel(int level) = 0;
        virtual int registerMapCallback(void(*f)(std::vector<point> points)) = 0;
        virtual bool unregisterMapCallback(int callbackId) = 0;
        virtual bool startPlaneDetect(int type,void(*f)(NxrPlaneData *data)) = 0;
        virtual bool stopPlaneDetect(int type) = 0;
        virtual void registerImuCallback(void(*f)(NxrRawData *data)) = 0;
        virtual void registerOrientationCallback(void(*f)(NxrTrackingData *data)) = 0;
        virtual void registerEventCallback(void(*f)(int type,int state)) = 0;
        virtual int registerCnnRawCallback(void(*f)(NxrCnnRawData *data)) = 0;
        virtual bool unregisterCnnRawCallback(int callbackId) = 0;
        virtual int registerCallback(void(*f)(std::vector<NxrCnnObject> object)) = 0;
        virtual bool unregisterCallback(int callbackId) = 0;
        virtual std::vector<std::pair<int, NxrTrackingData>> detectTags(std::string const &tagFamliy,double size) = 0;
        virtual void unregisterImuCallback() = 0;
        virtual void unregisterEventCallback() = 0;
        virtual void unregisterOrientationCallback() = 0;
        virtual void unregisterPoseCallback() = 0;
        virtual bool startMesh(void(*f)(std::map<uint64_t,NxrSurface> surfaces)) = 0;
        virtual void stopMesh() = 0;

        virtual int startETGaze(void(*f)(ETGazeData *data)) = 0;
        virtual bool stopETGaze(int callbackId) = 0;
        virtual int startETGazeCalibration(int points) = 0;
        virtual int startETGazeCalibrationPoints(int eye,int index,ETPoint2D *point,void(*f1)(int index,int percent,void *ctx),void *ctx1,void(*f2)(int index,int error,void *ctx),void *ctx2) = 0;
        virtual int cancelETGazeCalibration(int eye) = 0;
        virtual int computeETGazeCalibration(int eye,ETCoefficient *out) = 0;
        virtual ETCoefficient getETCoefficient(int eye) = 0;
        virtual int completeETGazeCalibration() = 0;
        virtual int setETGazeDefaultCalibration(int eye,float minX,float maxX,float minY,float maxY,const ETCoefficient *coe) = 0;
        virtual int inputETGazeCameraImage(const unsigned char *image,int size,int width,int height,long long timestamp) = 0;

        virtual bool startStreamingV4(StreamType type,void(*f)(StreamType type,NxrStreamV4 *stream)) = 0;
        virtual bool stopStreamingV4(StreamType type) = 0;

        virtual bool setRgbResolution(int code) = 0;
        virtual bool setRgbFormat(int code) = 0;
        virtual bool setExposureMode(int mode) = 0;
        virtual bool setRgbAWB(int nAWB) = 0;
        virtual bool setRgbISO(int nISO) = 0;
        virtual bool setRgbEXP(int nEXP) = 0;
        virtual double getRgbHostTimestamp() = 0;
        virtual int64_t getRgbEdgeTimestampUs() = 0;

        virtual int getPixelShift(float *dest,double prediction,double *pixelShift) = 0;
        virtual bool readStereoFisheyesSeucmCalibration(FishEyeSeucmCalibration &calibration) = 0;
        virtual int getPixelShiftV2(float *dest,float *predest,double *pixelShift) = 0;
        virtual int readDisplayCalibrationV2(NxrDisplayCalibration *calibration) = 0;
        virtual int getPixelShiftV3(double prediction_1,double prediction_2,double *pixelShift) = 0;
        virtual void sendSLIPData(const unsigned char* data, int dataLen) = 0;
        virtual void registerSLIPCallback(void(*f)(SLIPData *)) = 0;
        virtual std::vector<int> getNVStatus() = 0;
        virtual int getLPStatus() = 0;
        virtual float getAzimuth() = 0;
        virtual float getLightDegreeValue() = 0;
        virtual void saveMagCalibrationParam(float* offset, float* scale, uint64_t timestamp) = 0;
        virtual void readMagCalibrationParam(MagParamter &magParamter) = 0;
    };
};//nxr_client

#endif //INXRSENSOR_CLIENT_H
